# Contributor: Hugo Osvaldo Barrera <hugo@whynothugo.nl>
maintainer="Hugo Osvaldo Barrera <hugo@whynothugo.nl>"
pkgname=ublock-origin
pkgver=1.60.0
pkgrel=0
pkgdesc="Efficient blocker add-on for Firefox"
url="https://github.com/gorhill/uBlock"
arch="noarch"
license="GPL-3.0-or-later"
makedepends="git python3 zip bash strip-nondeterminism"
# Upstream's build script pulls latest master for uAssets.
# Pin the versions we use so we don't need network at built-time and the package
# sources are deterministic.
_uassets_master=bd1474d70d7d6e3c2ec8071231dfb894cd9ecec1
_uassets_ghpages=a6bac882b2a0629a45cadedd9c0fe5673dfde367
source="ublock-origin-$pkgver.tar.gz::https://github.com/gorhill/uBlock/archive/refs/tags/$pkgver.tar.gz
	uAssets-$_uassets_master.tar.gz::https://github.com/uBlockOrigin/uAssets/archive/$_uassets_master.tar.gz
	uAssets-$_uassets_ghpages.tar.gz::https://github.com/uBlockOrigin/uAssets/archive/$_uassets_ghpages.tar.gz
"
builddir="$srcdir/uBlock-$pkgver"
options="!check" # no tests

prepare() {
	default_prepare

	mkdir -p dist/build/uAssets
	mv ../uAssets-$_uassets_master dist/build/uAssets/main
	mv ../uAssets-$_uassets_ghpages dist/build/uAssets/prod
}

build() {
	make firefox
	strip-nondeterminism -t zip -T "$SOURCE_DATE_EPOCH" dist/build/uBlock0.firefox.xpi
}

package() {
	install -Dm644 dist/build/uBlock0.firefox.xpi "$pkgdir/usr/lib/firefox/browser/extensions/uBlock0@raymondhill.net.xpi"
}

sha512sums="
6723e2d337157b5d2a12659ee4389c241cd8581ccec3315c5d54cfd9d2bbedce52e2f76eb05f3a7d0f7ce1591a024ceb6da6b14891b4a27c5b101337f60e90e0  ublock-origin-1.60.0.tar.gz
3d46d406aa467dfda063ba9f58452849a2ffac7a7f623bb78eacdf2126b27735fe093dd6f9e197539b68047c297381c8364b62c0b95c4b4763d6608558d980d3  uAssets-bd1474d70d7d6e3c2ec8071231dfb894cd9ecec1.tar.gz
e7020fe8b06ed1f2ee780b5c918272783e6df08b47c2ebcec1b5e477b5c4e2c29bcedf9edb288b2fcbc22ae22e26491309c609acadc34b98e6bb93f9ef715aad  uAssets-a6bac882b2a0629a45cadedd9c0fe5673dfde367.tar.gz
"
